package com.cskaoyan.servlet;

import com.cskaoyan.util.URIUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author stone
 * @date 2023/03/20 11:45
 */
public abstract class WdBaseServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String operation = URIUtil.getOperation(this.getClass(),req);

        handle(operation,req,resp);
    }

    protected abstract void handle(String operation, HttpServletRequest request, HttpServletResponse response) throws IOException;
}
